

//5 3 10 12
cc.Class({
    extends: cc.Component,

    properties: {
        itemTemplate: { // item template to instantiate other items
            default: null,
            type: cc.Node
        },

        scrollView: {
            default: null,
            type: cc.ScrollView
        },

        spawnCount: 0,
        DataArray:{
            default:null,
            type:Array
        }


    },

    onLoad: function () {
        this.initManager();
        this.content = this.scrollView.content;
        this.items = []; // array to store spawned items
        this.initialize();
    },

    initManager: function()
    {
        console.log("call func initManager");
        
        var UserManager = require("UserManager");
        var userManager = new UserManager();
        userManager.loadDataTable();
        this.DataArray = userManager.getLocalTable();
        console.log("DataArray size = " + this.DataArray.length);
    },

    initialize: function () {
        for (let i = 0; i < this.spawnCount; ++i) { // spawn items, we only need to do this once
            let item = cc.instantiate(this.itemTemplate);
            this.content.addChild(item);
            item.setPosition(0, -item.height * (0.5 + i) - this.spacing * (i + 1));
            item.getComponent('Item').updateItem(i);
            this.items.push(item);
        }
    },

    update: function (dt) {
        
    }

});
